home *** CD-ROM | disk | FTP | other *** search
- Path: chronicle.mti.sgi.com!austern
- From: clamage@Eng.Sun.COM (Steve Clamage)
- Newsgroups: comp.std.c++
- Subject: Re: Referencing pointers after delete
- Date: 21 Mar 1996 13:50:12 PST
- Organization: Sun Microsystems Inc.
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <4isibn$el3@engnews1.Eng.Sun.COM>
- References: <4is60i$ft6@galaxy.ucr.edu>
- Reply-To: clamage@Eng.Sun.COM
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 21 Mar 1996 21:40:07 GMT
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMVHPLUy4NqrwXLNJAQFY5AH/TZETmkaO7tgOKmbLxYy6niBGvq9CSJTa
- bMjoH7ZH7ROmptlVHOVzX/fWomt8iZr7oxi8w851xSEN4Wk+EMQ46A==
- =bhe7
- Originator: austern@isolde.mti.sgi.com
-
- In article ft6@galaxy.ucr.edu, thp@cs.ucr.edu (Tom Payne) writes:
- >.... It seems that to accomodate
- >certain hardware-based validity checkers for pointers, the standard
- >has precluded the possibility of portable software-based validity
- >checking. IMHO an unfortunate decision.
-
- Even if the value of a pointer after its referent was deleted were
- required to be valid, it is still not possible to write a portable pointer
- validity checker for C or C++. Example, assuming that it is always safe
- to read the value of any pointer:
-
- void foo(int* p) {
- // is p valid?
- }
- How are you going to determine portably whether p is valid in foo?
-
- I might call foo like this, for example:
- int f2() {
- struct two { int a, b; } ray[10];
- foo(&ray[5].b);
- }
- The value of p in foo is valid, even though it does not correspond to any
- heap object or the start of any entire object. Furthermore, suppose in foo
- I save the value of p in a static variable and use it again in another
- invocation of foo. Is it still valid? If the current address of p
- is the same as the saved value from a previous invocation, does it refer
- to the same object?
-
- These questions can be answered in system-specific ways, but there is
- no portable method. A saved address might or might not still be valid.
- Addresses that compare equal might refer to the same or to different
- objects.
- ---
- Steve Clamage, stephen.clamage@eng.sun.com
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-